package com.mzq.langchain4j_springboot.web.service.Impl;

import com.mzq.langchain4j_springboot.web.entity.RentInfo;
import com.mzq.langchain4j_springboot.web.mapper.RentInfoMapper;
import com.mzq.langchain4j_springboot.web.service.RentInfoService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 租户信息服务实现类
 */
@Service
public class RentInfoServiceImpl implements RentInfoService {

    @Resource
    private RentInfoMapper rentInfoMapper;

    @Override
    public int insertRentInfo(RentInfo rentInfo) {
        return rentInfoMapper.insertRentInfo(rentInfo);
    }

    @Override
    public int updateRentInfo(RentInfo rentInfo) {
        return rentInfoMapper.updateRentInfo(rentInfo);
    }

    @Tool("根据租赁ID查询租赁信息")
    public List<Map<String, Object>> getRentById(
            @P("租赁ID") String rentId
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentId(rentId);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据签订地点查询租赁信息")
    public List<Map<String, Object>> getRentBySignLocation(
            @P("签订地点") String signLocation
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setSignLocation(signLocation);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据签订时间查询租赁信息")
    public List<Map<String, Object>> getRentBySignTime(
            @P("签订时间") String signTime
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setSignTime(signTime);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租赁期限查询租赁信息")
    public List<Map<String, Object>> getRentByRentLimit(
            @P("租赁期限") String rentLimit
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentLimit(rentLimit);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租金查询租赁信息")
    public List<Map<String, Object>> getRentByRentAmount(
            @P("租金") String rentAmount
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentAmount(rentAmount);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租金附件名称查询租赁信息")
    public List<Map<String, Object>> getRentByAmountName(
            @P("租金附件名称") String amountName
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setAmountName(amountName);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租金附件路径查询租赁信息")
    public List<Map<String, Object>> getRentByAmountPath(
            @P("租金附件路径") String amountPath
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setAmountPath(amountPath);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租金确认状态查询租赁信息")
    public List<Map<String, Object>> getRentByAmountType(
            @P("租金确认状态") String amountType
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setAmountType(amountType);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据承租人ID查询租赁信息")
    public List<Map<String, Object>> getRentByLesseeId(
            @P("承租人ID") String lesseeId
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setLesseeId(lesseeId);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据房屋ID查询租赁信息")
    public List<Map<String, Object>> getRentByHouseId(
            @P("房屋ID") String houseId
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setHouseId(houseId);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据合同名字查询租赁信息")
    public List<Map<String, Object>> getRentByContractName(
            @P("合同名字") String contractName
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setContractName(contractName);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据合同路径查询租赁信息")
    public List<Map<String, Object>> getRentByContractPath(
            @P("合同路径") String contractPath
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setContractPath(contractPath);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据合同确认状态查询租赁信息")
    public List<Map<String, Object>> getRentByContractType(
            @P("合同确认状态") String contractType
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setContractType(contractType);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租金单位查询租赁信息")
    public List<Map<String, Object>> getRentByRentUnit(
            @P("租金单位") String rentUnit
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentUnit(rentUnit);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据免租期查询租赁信息")
    public List<Map<String, Object>> getRentByRentFree(
            @P("免租期") String rentFree
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentFree(rentFree);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据到期时间查询租赁信息")
    public List<Map<String, Object>> getRentByExpireTime(
            @P("到期时间") String expireTime
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setExpireTime(expireTime);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据开始时间查询租赁信息")
    public List<Map<String, Object>> getRentByStartTime(
            @P("开始时间") String startTime
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setStartTime(startTime);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据结束时间查询租赁信息")
    public List<Map<String, Object>> getRentByEndTime(
            @P("结束时间") String endTime
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setEndTime(endTime);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据业态查询租赁信息")
    public List<Map<String, Object>> getRentByBusinessFormat(
            @P("业态") String businessFormat
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setBusinessFormat(businessFormat);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据创建人ID查询租赁信息")
    public List<Map<String, Object>> getRentByCreateId(
            @P("创建人ID") String createId
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setCreateId(createId);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据创建人查询租赁信息")
    public List<Map<String, Object>> getRentByCreateUser(
            @P("创建人") String createUser
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setCreateUser(createUser);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据创建时间查询租赁信息")
    public List<Map<String, Object>> getRentByCreateTime(
            @P("创建时间") String createTime
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setCreateTime(createTime);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据租赁形式查询租赁信息")
    public List<Map<String, Object>> getRentByRentType(
            @P("租赁形式") String rentType
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setRentType(rentType);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据挂牌方式查询租赁信息")
    public List<Map<String, Object>> getRentBySignType(
            @P("挂牌方式") String signType
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setSignType(signType);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据合同号查询租赁信息")
    public List<Map<String, Object>> getRentByContract(
            @P("合同号") String contract
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setContract(contract);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }

    @Tool("根据房屋名称查询租赁信息")
    public List<Map<String, Object>> getRentByHouseName(
            @P("房屋名称") String houseName
    ) {
        RentInfo rentInfo = new RentInfo();
        rentInfo.setHouseName(houseName);
        return rentInfoMapper.selectRentInfoList(rentInfo);
    }
}
